package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findList(dto);
    }
    @PostMapping("/submit")
    public  ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }
    @GetMapping("/one/{id}")
    public ResponseResult editNews(@PathVariable("id") Integer id){
        return wmNewsService.editNews(id);
    }
    @GetMapping("/del_news/{id}")
    public ResponseResult deleteNews(@PathVariable("id")Integer id){
        return wmNewsService.deleteNews(id);
    }
    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto dto){
        return wmNewsService.downOrUp(dto);
    }

    /**
     * 人工审核 查询文章列表
     */
    @PostMapping("/list_vo")
    public ResponseResult adminFindList(@RequestBody NewsAuthDto dto){
        return wmNewsService.adminFindList(dto);
    }

    /**
     * 查看文字详情
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult newsDetails(@PathVariable("id") Integer id){
        return wmNewsService.newsDetails(id);
    }

    /**
     * 审核失败
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody NewsAuthDto dto){
        return wmNewsService.authFail(dto);
    }

    /**
     * 审核通过
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody NewsAuthDto dto){
        return wmNewsService.authPass(dto);
    }


}
